#pragma once

#include <windows.h>
#include <stdio.h>

#include "ViewerDefine.h"

#include "D3DSetting.h"
#include "Timer.h"
#include "FontMng.h"
#include "Input.h"
#include "Camera.h"

#include ".\Animation.h"
#include ".\ObjectMng.h"
#include ".\ToolStructure.h"


struct RenderOption
{
	int		iCullMode;
	int		iFillMode;
	bool	bLight;
	int		iLightType;	
	bool	bRebderBiped;
	

	RenderOption()
	{
		iCullMode	= D3DCULL_CCW;
		iFillMode	= D3DFILL_SOLID;
		bLight		= true;
		iLightType	= 0;
		bRebderBiped = false;		
	};
};

class CEngine :	
	public CD3DSetting
{
public:
	CD3DSetting					m_D3DSetting;
	CTimer						m_Timer;
	CFontMng					m_FontMng;	
	CInput						m_Input;
	CCamera						m_Camera;

	CObjectMng					m_ObjectMng;
	CAnimation					m_Animation;
	ToolData					m_ToolMng;
    

public:
	DWORD						m_nVBSize;
	LPDIRECT3DVERTEXBUFFER9		m_pVB;
	//LPDIRECT3DINDEXBUFFER9		m_pIB;
	LPDIRECT3DINDEXBUFFER9		m_pIB[3];

	WORD*						m_pIndex;
	int							m_nIndex;

public:
	// Another Option
    float						m_fBGCRed , m_fBGCGreen , m_fBGCBlue;

public:
	bool						m_bMouseLButton;
	bool						m_bMouseRButton;
	bool						m_bAnimPlay;
	//bool						m_bBipRender;
	bool						m_bReverse;
	bool						m_bEditAnimPlay;
	bool						m_bChangeModel;

	RenderOption				m_RenderOption;
	

public:
	BOOL					Init();
	BOOL					Frame();
	BOOL					Render();
	BOOL					Release();	

	BOOL					OutputInfo();	

    //	For Hujub Viewer
	VOID					CreateObjMng( TCHAR* szGeomPath , TCHAR* szMtrlFile , bool bChange = false );
	VOID					CreateAnim( TCHAR* szAnim );

	// Render Option Change	
	VOID					SetupLight();
	VOID					SetupD3DMateial();

	VOID					RenderStateFrame();

public:
	CEngine(void);
	~CEngine(void);
};
